// !@#$McCaBe-InStRuMeNtAtIoN$#@!
// Instrumented with the McCabe Java Parser
// Version: 8.1.0.1 - 20110309
// Using Path Vector Instrumentation
// Date: Sun Apr 01 2012 20:41:02
package EventManager;

import java.util.ArrayList;

import Driver.Facade;
import Model.Event;

import com.mccabe.*;


class ViewAllEventsRequest_f46413c7ac09ab2f814067adfaeeba61 {
    static java.lang.Object info[];
    static {
        info = new java.lang.Object[2];
        info[0] = new Integer(-1);
        info[1] = new String("R:\\yu\\Concordia\\SOEN 344 Design II\\Term Assignment\\Code Repo\\trunk\\Iteration 3\\ERS\\src\\EventManager\\ViewAllEventsRequest.java");
    }
}


/**
 * A User request that returns the list of all events in the catalog, if sustained.
 * @author Yury Kitaev
 *
 */
public class ViewAllEventsRequest extends UserRequest
{
	private ArrayList<Model.Event> events;
	private boolean onlyOpen;
	
	public ViewAllEventsRequest(boolean onlyOpen)
	{
		super();
int _mcFreq_5ccf0145763c289e2dd9c0820241fe1e[] = PathVec_ERS_Iter3.getIntArray(0);
PathVec_ERS_Iter3.releaseIntArray();
PathVec_ERS_Iter3.enterConstructorWithECC(ViewAllEventsRequest_f46413c7ac09ab2f814067adfaeeba61.info,0,_mcFreq_5ccf0145763c289e2dd9c0820241fe1e,0);

		this.onlyOpen = onlyOpen;
	}

	/**
	 * Processes the request and updates itself. Sets the "events" attribute to the list of all events in the catalog.
	 */
	@Override
	public void process()
	{
int _mcFreq_6a0e2fd15685aa5a3bb610a18ee5830c[] = new int[5];
PathVec_ERS_Iter3.enterMethod(ViewAllEventsRequest_f46413c7ac09ab2f814067adfaeeba61.info,1,_mcFreq_6a0e2fd15685aa5a3bb610a18ee5830c,0);

		ArrayList<Event> eventsRetrieved = Facade.getCatalog().getEvents(onlyOpen);
		if (
PathVec_ERS_Iter3.decision(ViewAllEventsRequest_f46413c7ac09ab2f814067adfaeeba61.info,1,_mcFreq_6a0e2fd15685aa5a3bb610a18ee5830c,1,2,
PathVec_ERS_Iter3.testCondition(null != eventsRetrieved
))

				&& 
PathVec_ERS_Iter3.decision(ViewAllEventsRequest_f46413c7ac09ab2f814067adfaeeba61.info,1,_mcFreq_6a0e2fd15685aa5a3bb610a18ee5830c,3,4,
PathVec_ERS_Iter3.testCondition(eventsRetrieved.size() > 0
))
)
		{
			setEvents(eventsRetrieved);
			setStatus(RequestStatus.Sustained);
		}
		else
		{
			setEvents(eventsRetrieved);
			setStatus(RequestStatus.Refused);
		}
	}
	
	public ArrayList<Model.Event> getEvents() 
	{
int _mcFreq_d01dcea9e5051025ff0c0889042a95ed[] = new int[1];
PathVec_ERS_Iter3.enterMethod(ViewAllEventsRequest_f46413c7ac09ab2f814067adfaeeba61.info,2,_mcFreq_d01dcea9e5051025ff0c0889042a95ed,0);

		return events;
	}

	public void setEvents(ArrayList<Model.Event> events) 
	{
int _mcFreq_5aded435c88cebc476a1a4736d98ae99[] = new int[1];
PathVec_ERS_Iter3.enterMethod(ViewAllEventsRequest_f46413c7ac09ab2f814067adfaeeba61.info,3,_mcFreq_5aded435c88cebc476a1a4736d98ae99,0);

		this.events = events;
	}

	@Override
	public String toString() 
	{
int _mcFreq_85f4edad78b3099e35ade07820795d09[] = new int[3];
PathVec_ERS_Iter3.enterMethod(ViewAllEventsRequest_f46413c7ac09ab2f814067adfaeeba61.info,4,_mcFreq_85f4edad78b3099e35ade07820795d09,0);

		return "View All Events" + (
PathVec_ERS_Iter3.decision(ViewAllEventsRequest_f46413c7ac09ab2f814067adfaeeba61.info,4,_mcFreq_85f4edad78b3099e35ade07820795d09,1,2,
PathVec_ERS_Iter3.testCondition(onlyOpen
))
? " that are open" : ", both closed and open");
	}
}
